package cn.jlearn.proxy.web.exception;

import cn.dev33.satoken.exception.NotLoginException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.view.RedirectView;

/**
 * 统一异常处理器
 *
 * @author qianyingchao
 * @version 1.0
 * @date 2020/12/29 2:34 下午
 */
@ControllerAdvice
public class GlobalExceptionHandler {

    private final Logger logger = LoggerFactory.getLogger(getClass());

    @ExceptionHandler(NotLoginException.class)
    public ModelAndView handleNotLoginException(NotLoginException e) {
        return new ModelAndView(new RedirectView("/proxy/admin/login.html"));
    }

//    @ExceptionHandler(Exception.class)
//    public R<?> handleException(Exception e) {
//        logger.error(e.getMessage(), e);
//        return R.fail("500", e.getMessage());
//    }

}
